package great.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.ChainWrappers;
import great.project.mapper.SysRoleMenuMapper;
import great.project.mapper.SysUserMapper;
import great.project.pojo.entity.SysRoleMenu;
import great.project.pojo.entity.SysUser;
import great.project.service.SysRoleMenuService;
import great.project.service.SysUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author RichMan
 * @date 2020-12-27 23:18
 */
@Service
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements SysRoleMenuService {

    /**
     *   <div  style="height:10px;width:200px;font-size:15px;text-align:center;color:red;">
     *
     *  sysUserService
     *
     *  </div>
     */
    @Resource
    private SysUserService sysUserService;

    /**
     *   <div  style="height:10px;width:200px;font-size:15px;text-align:center;color:red;">
     *
     *  sysUserMapper
     *
     *  </div>
     */
    @Resource
    private SysUserMapper sysUserMapper;

    /**
     * <div  style="height:10px;width:200px;font-size:15px;text-align:center;color:red;">
     * <p>
     *  sysRoleMenuMapper
     *
     *  </div>
     */
    @Resource
    private SysRoleMenuMapper sysRoleMenuMapper;


    public void test() {

// --------------------------------------------------------------------------------------
        QueryWrapper<SysRoleMenu> role_id = new QueryWrapper<SysRoleMenu>()
                .eq("role_id", 1);

        List<SysRoleMenu> sysRoleMenus3 = sysRoleMenuMapper
                .selectList(role_id);

// --------------------------------------------------------------------------------------

        LambdaQueryWrapper<SysRoleMenu> eq = new QueryWrapper<SysRoleMenu>()
                .lambda()
                .eq(SysRoleMenu::getRoleId, 1);

        List<SysRoleMenu> sysRoleMenus = sysRoleMenuMapper
                .selectList(eq);

// --------------------------------------------------------------------------------------

        LambdaQueryWrapper<SysRoleMenu> eq1 = new LambdaQueryWrapper<SysRoleMenu>()
                .eq(SysRoleMenu::getRoleId, 1);


        List<SysRoleMenu> sysRoleMenus1 = sysRoleMenuMapper
                .selectList(eq1);

// --------------------------------------------------------------------------------------

        QueryWrapper<SysRoleMenu> role_id1 = Wrappers.<SysRoleMenu>query()
                .eq("role_id", 1);

        List<SysRoleMenu> sysRoleMenus4 = sysRoleMenuMapper
                .selectList(role_id1);
        // --------------------------------------------------------------------------------------

        LambdaQueryWrapper<SysRoleMenu> role_id2 = Wrappers.<SysRoleMenu>lambdaQuery()
                .eq(SysRoleMenu::getRoleId, 1);

        List<SysRoleMenu> sysRoleMenus5 = sysRoleMenuMapper
                .selectList(role_id2);

// --------------------------------------------------------------------------------------

        List<SysRoleMenu> list = new LambdaQueryChainWrapper<>(getBaseMapper())
                .eq(SysRoleMenu::getRoleId, 1)
                .list();

// --------------------------------------------------------------------------------------

        List<SysRoleMenu> list1 = ChainWrappers.lambdaQueryChain(getBaseMapper())
                .eq(SysRoleMenu::getRoleId, 1)
                .list();

// --------------------------------------------------------------------------------------

        List<SysRoleMenu> list2 = lambdaQuery()
                .eq(SysRoleMenu::getRoleId, 1)
                .list();


// --------------------------------------------------------------------------------------

        List<SysUser> list3 = sysUserService
                .lambdaQuery()
                .eq(SysUser::getUserId, 1)
                .list();


    }

}
